package com.weigee.ktv.m.subscribe;

import android.support.annotation.NonNull;

import com.weigee.ktv.m.observer.DrawerLayoutObserver;

import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;

/**
 * Created by 林德 on 2017/4/5 10:35.
 * <p/>
 */
public class DrawerLayoutSubscribe implements ObservableOnSubscribe<Integer>
{
    private int mDirection;

    public DrawerLayoutSubscribe()
    {
        mDirection = DrawerLayoutObserver.LEFT_OPEN;
    }

    public void setDirection(int direction)
    {
        mDirection = direction;
    }

    @Override
    public void subscribe(@NonNull ObservableEmitter<Integer> e) throws Exception
    {
        if (mDirection == DrawerLayoutObserver.COMPLETE)
        {
            e.onComplete();
        } else
        {
            e.onNext(mDirection);
        }
    }
}
